<?php

use yii\db\Schema;
use yii\db\Migration;

class m160122_094749_add_solution_balance_cost_today extends Migration
{
    public function up()
    {
        $this->addColumn('{{%solution_balance}}', 'cost_yesterday', "decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT 'server 昨日记录的花费' after cost_from_log");
        $this->addColumn('{{%solution_balance}}', 'cost_today', "decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT 'server 今日记录的花费' after cost_yesterday");
        $this->dropColumn('{{%solution_balance}}', 'cost_from_server');
        $this->addColumn('{{%solution_balance}}', 'hours', "int(11) NOT NULL DEFAULT '0' comment '策略总时长' after balance");
        $this->dropColumn('{{%solution_balance}}', 'days');
    }

    public function down()
    {
        $this->dropColumn('{{%solution_balance}}', 'cost_yesterday');
        $this->dropColumn('{{%solution_balance}}', 'cost_today');
        $this->addColumn('{{%solution_balance}}', 'cost_from_server', "decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT 'server 记录的花费' after cost_from_log");
        $this->addColumn('{{%solution_balance}}', 'days', "int(11) NOT NULL DEFAULT '0' after balance");
        $this->dropColumn('{{%solution_balance}}', 'hours');
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
